<?php
include_once("season.php");
if(class_exists('SQL_Helper') != true)
{
   include_once("sql_helper.php");
}
class SeasonsRepository
{

function createSeason($seasonID, $seasonName, $start_date,$end_date){
	SQL_Helper::executeNonQuery("INSERT INTO `seasons` (`seasonID`, `seasonName`, `start_date`, `start_date`) VALUES(null, ?, ?, ?)",$seasonName, $start_date,$end_date);
}

function readSeason($seasonID){
	return SQL_Helper::executeQuerySingle("Select * from `seasons` where `seasonID` = ?", $seasonID);
}

function updateSeason($seasonID, $seasonName, $start_date, $end_date){
	SQL_Helper::executeNonQuery("Update `seasons` set `seasonName`=?, `start_date`=?, `end_date`=? where `seasonID` = ?",$seasonName, $start_date,$end_date,$seasonID);
}

function deleteRound($seasonID){
	SQL_Helper::executeNonQuery("delete from `seasons` where `seasonID` = ?", $seasonID);
}

function map($row){
	$class= "Season";
	return SQL_Helper::sql_map($row,$class);
}

function maps($rows){
		$class= "Season";
		return SQL_Helper::sql_maps($rows,$class);
}

function getSeasonByDate($date){
	return SQL_Helper::executeQuerySingle("SELECT * FROM `seasons` WHERE `start_date`<=? and `end_date`>=?", $date, $date);
}

function allSeasons(){
	return SQL_Helper::executeQuery("SELECT * FROM `seasons` order by `seasonID` DESC ");
}

}
?>